﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Orid.Management.SOHO.Book.ServiceLibrary.Logic
{
    public class Log
    {

        // public static log4net.ILog log ;
        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

     

        public static void Error(string Message, Exception ex)
        {
            log.Error(Message, ex);
        }

        public static void Error(string Message)
        {
            log.Error(Message);
        }

        public static void Info(string Message, Exception ex)
        {
            log.Info(Message, ex);
        }
        public static void Info(string Message)
        {
            log.Info(Message);
        }

        public static void Warn(string Message, Exception ex)
        {
            log.Warn(Message, ex);
        }

        public static void Warn(string Message)
        {
            log.Warn(Message);
        }

        public static void initLog4Net()
        {
            //注意这里不写全路径可能导致无法找到配置文件
            FileInfo file = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config");
            if (File.Exists(file.ToString()))
            {
                log4net.Config.XmlConfigurator.Configure(file);
            }
            else
            {
                throw new Exception("log4net日志配置文件未找到");
            }
        }


    }
}
